package com.darrenchan.leetcode;

/**
 * @Desc
 * @Author chenchi03
 * @CreateTime 2019-12-29 20:17
 */
abstract class GuessGame {
    abstract int guess(int num);
}

public class Q374 extends GuessGame {

    public int guessNumber(int n) {
        int start = 1, end = n;
        while (start + 1 < end) {
            int mid = start + (end - start) / 2;
            if (guess(mid) == 1) {
                start = mid;
            } else {
                end = mid;
            }
        }

        if(guess(start) == 0) {
            return start;
        }
        return end;
    }

    @Override
    int guess(int num) {
        return 0;
    }
}
